﻿import QtQuick 2.0

Item {
    // 管道节点
    property int vertexNum: 26
    property var vertex: [
        { idx: 0,   x: 0.163,  y: 0.678 },
        { idx: 1,   x: 0.124,  y: 0.608 },
        { idx: 2,   x: 0.200,  y: 0.608 },
        { idx: 3,   x: 0.272,  y: 0.608 },
        { idx: 4,   x: 0.339,  y: 0.608 },
        { idx: 5,   x: 0.402,  y: 0.608 },
        { idx: 6,   x: 0.458,  y: 0.608 },
        { idx: 7,   x: 0.508,  y: 0.642 },
        { idx: 8,   x: 0.571,  y: 0.660 },
        { idx: 9,   x: 0.620,  y: 0.660 },
        { idx: 10,  x: 0.650,  y: 0.660 },
        { idx: 11,  x: 0.698,  y: 0.660 },
        { idx: 12,  x: 0.163,  y: 0.608 },
        { idx: 13,  x: 0.272,  y: 0.742 },
        { idx: 14,  x: 0.339,  y: 0.678 },
        { idx: 15,  x: 0.402,  y: 0.678 },
        { idx: 16,  x: 0.458,  y: 0.642 },
        { idx: 17,  x: 0.508,  y: 0.678 },
        { idx: 18,  x: 0.533,  y: 0.678 },
        { idx: 19,  x: 0.533,  y: 0.742 },
        { idx: 20,  x: 0.508,  y: 0.266 },
        { idx: 21,  x: 0.651,  y: 0.266 },
        { idx: 22,  x: 0.571,  y: 0.708 },
        { idx: 23,  x: 0.620,  y: 0.708 },
        { idx: 24,  x: 0.700,  y: 0.708 },
        { idx: 25,  x: 0.723,  y: 0.580 },
    ]
    property var supVertex: [

        { x1: vertex[22].x,  y1: vertex[22].y, x2: vertex[22].x, y2: 0.808 },
        { x1: vertex[23].x,  y1: vertex[23].y, x2: vertex[23].x, y2: 0.808 },
        { x1: vertex[24].x,  y1: vertex[24].y, x2: vertex[24].x, y2: 0.808 },
        { x1: 0.732,  y1: 0.713, x2: 0.732, y2: 0.808 },
    ]

    function calDistance(v1, v2, baseX, baseY){
        let dx = Math.abs(vertex[v1].x-vertex[v2].x) * baseX
        let dy = Math.abs(vertex[v1].y-vertex[v2].y) * baseY
        return Math.sqrt(dx*dx + dy*dy)
    }

    // 针管位置(底座)
    property var syringe: [
        { idx: 0,  x: vertex[0].x,  y: vertex[0].y },
        { idx: 1,  x: vertex[1].x,  y: vertex[1].y },
        { idx: 2,  x: vertex[2].x,  y: vertex[2].y },
        { idx: 3,  x: vertex[3].x,  y: vertex[3].y },
        { idx: 4,  x: vertex[4].x,  y: vertex[4].y },
        { idx: 5,  x: vertex[5].x,  y: vertex[5].y },
        { idx: 6,  x: vertex[6].x,  y: vertex[6].y }
    ]

    // 底座
    property var base: ({
        x1: 0.08,  y1: 0.54,
        x2: 0.75,  y2: 0.79
    })

    // 色谱柱
    property var column: ({
        x: vertex[7].x,
        y: 0.46
    })

    // 检测器
    property var detector: ({
        x: vertex[8].x+0.005,
        y: vertex[21].y
    })

    // 阀门
    property var valve: [
        { idx: 0,   x: 0,  y: 0 },
        { idx: 1,   x: 0.154,       y: vertex[1].y,  angle: 0.5 },
        { idx: 2,   x: 0.172,       y: vertex[1].y,  angle: 0.5 },
        { idx: 3,   x: vertex[0].x, y: 0.649,  angle: 0 },
        { idx: 4,   x: 0.253,       y: 0.621,  angle: 0.34 },
        { idx: 5,   x: 0.390,       y: vertex[17].y,  angle: 0.5 },
        { idx: 6,   x: vertex[5].x, y: 0.625,  angle: 0 },
        { idx: 7,   x: 0.490,       y: vertex[7].y,  angle: 0.5 },
        { idx: 8,   x: 0.518,       y: vertex[17].y,  angle: 0.5 },
        { idx: 9,   x: 0.488,       y: vertex[17].y,  angle: 0.5 },
        { idx: 10,  x: vertex[8].x, y: 0.686,  angle: 0 },
        { idx: 11,  x: vertex[9].x, y: 0.686,  angle: 0 },
        { idx: 12,  x: 0.640,       y: vertex[9].y,  angle: 0.5 },
        { idx: 13,  x: 0.712,       y: 0.612,  angle: 0.2 },
        { idx: 14,  x: 0.672,       y: vertex[9].y,  angle: 0.5 },
        { idx: 15,  x: 0.698,       y: 0.676,  angle: 0.95 },
    ]

    // 阀门旁边标注的偏离位置
    property var valveLabel: [
        { idx: 0,  x: 0, y: 0 },
        { idx: 1,  x: -1, y: 0.8 },
        { idx: 2,  x: 1, y: 0.8 },
        { idx: 3,  x: -1, y: 0.8 },
        { idx: 4,  x: 0, y: 1 },
        { idx: 5,  x: 0.2, y: 1 },
        { idx: 6,  x: 0.9, y: 0 },
        { idx: 7,  x: 0, y: -0.8 },
        { idx: 8,  x: -0.1, y: 1 },
        { idx: 9,  x: -0.3, y: 1 },
        { idx: 10, x: -0.6, y: 0.8 },
        { idx: 11, x: 0.6, y: 0.8 },
        { idx: 12, x: -0.6, y: -1 },
        { idx: 13, x: 0.9, y: 0 },
        { idx: 14, x: 0, y: -1 },
        { idx: 15, x: 0.9, y: 0.2 }
    ]

    // 废液瓶
    property var trashBin1: ({
         x: vertex[8].x,
         y: 0.8
    })
    property var trashBin2: ({
         x: vertex[9].x,
         y: 0.8
    })

}
